import java.util.Scanner;

public class Day_16_1_完全数计算 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int num = sc.nextInt();
            int res = countPerfect(num);
            System.out.println(res);
        }
    }
    private static int countPerfect(int num) {
        int count = 0;
        for(int i = 1; i < num; i++) {
            int sum = 0;
            for(int j = 1; j <= i/2; j++) {
                if(i % j == 0) {
                    sum += j;
                }
            }
            if(sum == i) {
                count ++;
            }
        }
        return count;
    }
}
